<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/country.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><?php echo $button_cancel; ?></a></div>
    </div>
    <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
        <table class="form">
          <tr>
            <td><?php echo $entry_country; ?></td>
            <td>
              <div style="float: left;"><?php echo $text_country_search; ?><input type="text" name="country_search" value="" /></div>
              <div style="float: left;margin-left: 15px;">
            	<input type="hidden" id="country_id" name="country_id" value="<?php echo $country_id; ?>"/>
              	<b><?php echo $text_country_name; ?></b>&nbsp;&nbsp;<span id="country_name"><?php echo $country_name; ?></span><br/>
              	<b><?php echo $text_country_display_name; ?></b>&nbsp;&nbsp;<span id="country_display_name"><?php echo $country_display_name; ?></span><br/>
              	<b><?php echo $text_country_iso_code; ?></b>&nbsp;&nbsp;<span id="country_iso_code"><?php echo $country_iso_code; ?></span><br/>
              </div>
            </td>
          </tr>
          <tr>
            <td><?php echo $entry_zone; ?></td>
            <td>
              <div style="float: left;"><?php echo $text_zone_search; ?><input type="text" name="zone_search" value="" /></div>
              <div style="float: left;margin-left: 15px;">
            	<input type="hidden" id="country_zone_id" name="country_zone_id" value="<?php echo $country_zone_id; ?>"/>
              	<b><?php echo $text_zone_name; ?></b>&nbsp;&nbsp;<span id="country_zone_name"><?php echo $country_zone_name; ?></span><br/>
              	<b><?php echo $text_zone_display_name; ?></b>&nbsp;&nbsp;<span id="country_zone_display_name"><?php echo $country_zone_display_name; ?></span><br/>
              	<b><?php echo $text_zone_code; ?></b>&nbsp;&nbsp;<span id="country_zone_code"><?php echo $country_zone_code; ?></span><br/>
              </div>
            </td>
          </tr>
          <tr>
            <td><?php echo $entry_name; ?></td>
            <td><input type="text" name="name" value="<?php echo $name; ?>" size="50"/></td>
          </tr>
          <tr>
            <td><?php echo $entry_display_name; ?></td>
            <td><?php foreach ($languages as $language) { ?>
              <input type="text" name="country_city_description[<?php echo $language['language_id']; ?>][display_name]" value="<?php echo isset($country_city_description[$language['language_id']]) ? $country_city_description[$language['language_id']]['display_name'] : ''; ?>" size="50"/>
              <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /><br />
              <?php } ?></td>
          </tr>
          <tr>
            <td><?php echo $entry_code; ?></td>
            <td><input type="text" name="code" value="<?php echo $code; ?>" size="50"/></td>
          </tr>
          <tr>
            <td><?php echo $entry_postcode; ?></td>
            <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" size="50"/></td>
          </tr>
          <tr>
            <td><?php echo $entry_time_difference; ?></td>
            <td><input type="text" name="time_difference" value="<?php echo $time_difference; ?>" size="50"/></td>
          </tr>
          <tr>
            <td><?php echo $entry_status; ?></td>
            <td>
              <?php if ($status) { ?>
              <input name="status" type="radio" value="1" checked="checked"/><?php echo $text_enabled; ?>
              <input name="status" type="radio" value="0"/><?php echo $text_disabled; ?>
              <?php } else { ?>
              <input name="status" type="radio" value="1"/><?php echo $text_enabled; ?>
              <input name="status" type="radio" value="0" checked="checked"/><?php echo $text_disabled; ?>
              <?php } ?>
            </td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript"><!--	
$('input[name=\'country_search\']').autocomplete({
	delay: 0,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=localisation/country/autocomplete&token=<?php echo $token; ?>&filter_display_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item.display_name,
						value: item.country_id,
						name: item.name,
						iso_code: item.iso_code
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('#country_id').val(ui.item.value);
		$('#country_name').text(ui.item.name);
		$('#country_display_name').text(ui.item.label);
		$('#country_iso_code').text(ui.item.iso_code);
		return false;
	},
	focus: function(event, ui) {
      return false;
    }
});
//--></script>
<script type="text/javascript"><!--	
$('input[name=\'zone_search\']').autocomplete({
	delay: 0,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=localisation/country_zone/autocomplete&token=<?php echo $token; ?>&filter_country_id=' + $('#country_id').val() + '&filter_display_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item.display_name,
						value: item.country_zone_id,
						name: item.name,
						iso_code: item.code
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('#country_zone_id').val(ui.item.value);
		$('#country_zone_name').text(ui.item.name);
		$('#country_zone_display_name').text(ui.item.label);
		$('#country_zone_code').text(ui.item.code);
		return false;
	},
	focus: function(event, ui) {
      return false;
    }
});
//--></script>
<?php echo $footer; ?>